﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplicationCultura.Clases;

namespace WebApplicationCultura.Pages.Eventos
{
    public partial class modificarevento : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (Calendar1.Visible == false)
                {
                    Calendar1.Visible = true;
                    Button3.Text = "Ocultar";
                }
                else
                {
                    Calendar1.Visible = false;
                    Button3.Text = "Calendario";
                }
            }
            catch (Exception)
            {
            }
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (Calendar2.Visible == false)
                {
                    Calendar2.Visible = true;
                    Button4.Text = "Ocultar";
                }
                else
                {
                    Calendar2.Visible = false;
                    Button4.Text = "Calendario";
                }
            }
            catch (Exception)
            {
            }
        }

        protected void Calendar2_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                TextBox9.Text = Calendar2.SelectedDate.ToString();
            }
            catch (Exception)
            {
            }
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                TextBox8.Text = Calendar1.SelectedDate.ToString();
            }
            catch (Exception)
            {
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                culturaDataContext cdc = new culturaDataContext();
                EVENTO evento = new EVENTO();
                if (this.TextBox1.Text.Trim() != null)
                {
                    evento.NOMBRE_EVENTO = this.TextBox1.Text.Trim();
                }
                else
                {
                    Response.Write("<p>Debe escribir un nombre de evento</p>");
                }
                if (this.TextBox7.Text.Trim() != null)
                {
                    evento.UBICACION_EVENTO = this.TextBox7.Text.Trim();
                }
                else
                {
                    Response.Write("<p>Debe escribir un nombre de evento</p>");
                }
                if (this.TextBox8.Text.Trim() != null)
                {
                    evento.INICIO_EVENTO = this.Calendar1.SelectedDate;
                }
                else
                {
                    Response.Write("<p>Debe escribir una fecha de inicio v&aacute;lida</p>");
                }
                if (this.TextBox9.Text.Trim() != null)
                {
                    evento.FIN_EVENTO = this.Calendar2.SelectedDate;
                }
                else
                {
                    Response.Write("<p>Debe escribir una fecha de t&eacute;rmino v&aacute;lida</p>");
                }
                if (this.TextBox10.Text.Trim() != null)
                {
                    evento.AUDIENCIA_EVENTO = int.Parse(this.TextBox10.Text.Trim());
                }
                else
                {
                    Response.Write("<p>Debe escribir audiencia válida</p>");
                }
                if (this.TextBox11.Text.Trim() != null)
                {
                    evento.DESCRIPCION_EVENTO = this.TextBox11.Text.Trim();
                }
                else
                {
                    evento.DESCRIPCION_EVENTO = "Sin descripción";
                }
                cdc.EVENTOs.InsertOnSubmit(evento);
                cdc.SubmitChanges();

                Response.Redirect("/Pages/eventos.aspx");
              
            }
            catch (Exception)
            {
            }
        }
    }
}